package com.hospital.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.dto.PatientPageQueryDTO;
import com.hospital.entity.Patient;
import com.hospital.entity.TreatmentRecord;
import com.hospital.mapper.DoctorMapper;
import com.hospital.mapper.PatientMapper;
import com.hospital.mapper.TreatmentMapper;
import com.hospital.mapper.TreatmentRecordMapper;
import com.hospital.result.PageResult;
import com.hospital.service.TreatmentRecordService;
import com.hospital.vo.TreatmentRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TreatmentRecordServiceImpl extends ServiceImpl<TreatmentRecordMapper, TreatmentRecord> implements TreatmentRecordService {
    @Autowired
    private TreatmentRecordMapper treatmentRecordMapper;
    @Autowired
    private TreatmentMapper treatmentMapper;
    @Autowired
    private PatientMapper patientMapper;
    @Autowired
    private DoctorMapper doctorMapper;

    @Override
    public PageResult getTreatmentRecord(PatientPageQueryDTO patientPageQueryDTO) {
        IPage<TreatmentRecordVO> page = new Page<>(patientPageQueryDTO.getPageNumber(), patientPageQueryDTO.getPageSize());

        treatmentRecordMapper.pageQuery(page, patientPageQueryDTO.getName());

        return PageResult.builder()
                .total(page.getTotal())
                .records(page.getRecords())
                .build();
    }
}
